import multiprocessing
from logger import LogManager

# 多进程示例
logger = LogManager.get_both_logger(name='multiprocess_logger', log_file='examples/multiprocess_example.log', use_multiprocess=True)

def worker(process_id):
    logger.info(f'进程 {process_id} 正在执行任务')

if __name__ == '__main__':
    processes = []
    for i in range(3):
        p = multiprocessing.Process(target=worker, args=(i,))
        processes.append(p)
        p.start()

    for p in processes:
        p.join()

    logger.info('所有进程执行完毕')